From b92c7f696e00a8c3504c00c4c98df7f75192036f Mon Sep 17 00:00:00 2001 From: Christian Marangi Date: Tue, 21 Nov 2023 21:37:43 +0100 Subject: [PATCH] luci-mod-status: reorganize poll function for index page Reorganize poll function for index page. Drop the external function and use the poll_status pattern used in other page that use poll.add API. Signed-off-by: Christian Marangi --- .../luci-static/resources/view/status/index.js | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js index 911c187584..f19a5e4f5d 100644 --- a/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js +++ b/modules/luci-mod-status/htdocs/luci-static/resources/view/status/index.js @@ -24,8 +24,8 @@ function invokeIncludesLoad(includes) { return has_load ? Promise.all(tasks) : Promise.resolve(null); } -function startPolling(includes, containers) { - var step = function() { +return view.extend({ + poll_status: function(includes, containers) { return network.flushCache().then(function() { return invokeIncludesLoad(includes); }).then(function(results) { @@ -59,14 +59,8 @@ function startPolling(includes, containers) { ssi.classList.add('fade-in'); } }); - }; - - return step().then(function() { - poll.add(step); - }); -} + }, -return view.extend({ load: function() { return L.resolveDefault(fs.list('/www' + L.resource('view/status/include')), []).then(function(entries) { return Promise.all(entries.filter(function(e) { @@ -103,7 +97,9 @@ return view.extend({ containers.push(container); } - return startPolling(includes, containers).then(function() { + return this.poll_status(includes, containers).then(function() { + return poll.add(L.bind(this.poll_status, this, includes, containers)) + }).then(function() { return rv; }); }, -- 2.30.2